/*
*
* SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2011-2018 ARM or its affiliates
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2.
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "acamera_command_api.h"
//#include "acamera_firmware_api.h"
#include "acamera_firmware_settings.h"
// created from 2016-10-19T16:42:58.865Z UTClinear.json

// CALIBRATION_LIGHT_SRC
static uint16_t _calibration_light_src[][2] = {
  {286,237}};

// CALIBRATION_RG_POS
static uint16_t _calibration_rg_pos[]
 = {167,182,200,217,235,256,270,287,305,322,340,357,375,392,429};

// CALIBRATION_BG_POS
static uint16_t _calibration_bg_pos[]
 = {142,162,174,185,197,209,220,232,244,256,267,279,291,302,328};

// CALIBRATION_MESH_RGBG_WEIGHT
static uint16_t _calibration_mesh_rgbg_weight[][15] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 28 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 42, 256, 256 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 16, 78, 256, 256, 24 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 256, 256, 256, 153, 0 },
  { 0, 0, 0, 0, 0, 0, 1, 8, 43, 156, 256, 256, 165, 15, 0 },
  { 0, 0, 0, 0, 0, 2, 14, 65, 208, 256, 256, 185, 23, 1, 0 },
  { 0, 0, 0, 0, 1, 20, 77, 256, 256, 256, 186, 35, 2, 0, 0 },
  { 0, 0, 0, 0, 13, 118, 256, 256, 256, 180, 32, 2, 0, 0, 0 },
  { 0, 0, 0, 8, 90, 256, 256, 256, 168, 34, 2, 0, 0, 0, 0 },
  { 0, 0, 6, 76, 256, 256, 256, 164, 31, 3, 0, 0, 0, 0, 0 },
  { 0, 0, 40, 256, 256, 256, 161, 33, 3, 0, 0, 0, 0, 0, 0 },
  { 0, 5, 190, 256, 256, 89, 26, 3, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 47, 256, 256, 68, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 6, 256, 256, 73, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 57, 256, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};

// CALIBRATION_MESH_LS_WEIGHT
static uint16_t _calibration_mesh_ls_weight[][15] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 3, 4, 25, 42, 53, 57, 53, 42, 25, 4, 3, 0, 0 },
  { 0, 0, 4, 131, 157, 179, 193, 198, 193, 179, 157, 131, 4, 0, 0 },
  { 0, 0, 25, 157, 188, 214, 232, 238, 232, 214, 188, 157, 25, 0, 0 },
  { 0, 0, 42, 179, 214, 243, 255, 256, 255, 243, 214, 179, 42, 0, 0 },
  { 0, 0, 53, 193, 232, 255, 256, 256, 256, 255, 232, 193, 53, 0, 0 },
  { 0, 0, 57, 198, 238, 256, 256, 256, 256, 256, 238, 198, 57, 0, 0 },
  { 0, 0, 53, 193, 232, 255, 256, 256, 256, 255, 232, 193, 53, 0, 0 },
  { 0, 0, 42, 179, 214, 243, 255, 256, 255, 243, 214, 179, 42, 0, 0 },
  { 0, 0, 25, 157, 188, 214, 232, 238, 232, 214, 188, 157, 25, 0, 0 },
  { 0, 0, 4, 131, 157, 179, 193, 198, 193, 179, 157, 131, 4, 0, 0 },
  { 0, 0, 3, 4, 25, 42, 53, 57, 53, 42, 25, 4, 3, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};

// CALIBRATION_MESH_COLOR_TEMPERATURE
static uint16_t _calibration_mesh_color_temperature[][15] = {
  { 177, 191, 213, 231, 254, 269, 283, 299, 317, 333, 351, 366, 381, 396, 400 },
  { 166, 180, 197, 218, 236, 262, 271, 288, 305, 321, 339, 356, 371, 385, 400 },
  { 160, 174, 191, 211, 229, 254, 264, 281, 298, 314, 332, 348, 365, 379, 400 },
  { 154, 168, 185, 204, 222, 243, 260, 274, 292, 308, 325, 342, 359, 373, 400 },
  { 154, 161, 178, 194, 215, 236, 252, 267, 284, 301, 318, 335, 352, 367, 400 },
  { 154, 155, 172, 188, 207, 229, 243, 261, 277, 294, 311, 328, 345, 361, 400 },
  { 152, 154, 166, 182, 201, 222, 236, 254, 271, 288, 305, 321, 339, 355, 386 },
  { 144, 154, 160, 176, 193, 214, 228, 246, 264, 280, 298, 314, 332, 348, 380 },
  { 136, 147, 154, 169, 186, 207, 221, 238, 256, 273, 291, 307, 325, 341, 374 },
  { 133, 140, 153, 163, 180, 200, 214, 231, 249, 266, 284, 300, 318, 334, 367 },
  { 124, 133, 146, 157, 174, 194, 207, 224, 242, 258, 277, 294, 311, 328, 362 },
  { 115, 126, 138, 151, 167, 187, 200, 217, 235, 250, 270, 287, 304, 321, 356 },
  { 106, 117, 130, 143, 161, 181, 194, 209, 227, 245, 260, 280, 297, 314, 349 },
  { 100, 108, 122, 136, 149, 175, 188, 202, 221, 238, 252, 273, 291, 307, 342 },
  { 100, 100, 100, 114, 127, 161, 174, 190, 205, 222, 240, 252, 276, 292, 328 }};

// RG, BG, MULT. final wb gain adjuster for a sky scene. devided by CALIBRATION_WB_STRENGTH_MULT in use
static uint16_t _calibration_wb_strength[] = {1000, 1000, 1000};

// lux threshold for sky
static uint16_t _calibration_sky_lux_th[] = {10000};

// 1D rg/bg readout from color_temp
static uint16_t _calibration_ct_rg_pos_calc[]
 = {183,204,219,256,292,302,354,373,409};

// 1D rg/bg readout from color_temp
static uint16_t _calibration_ct_bg_pos_calc[]
 = {313,291,278,256,234,228,196,185,163};

// CALIBRATION_COLOR_TEMP
static uint16_t _calibration_color_temp[]
 = {100,133,154,200,250,263,333,357,400};

// CALIBRATION_CT65POS
static uint16_t _calibration_ct65pos[] = {2};

// CALIBRATION_CT40POS
static uint16_t _calibration_ct40pos[] = {8};

// CALIBRATION_CT30POS
static uint16_t _calibration_ct30pos[] = {6};

// CALIBRATION_EVTOLUX_EV_LUT
static uint32_t _calibration_evtolux_ev_lut[]
 = {101156,188068,303007,605059,944040,1216255,1296431,1473159,1820856,2067789,2319065,2994398,4858650};

// CALIBRATION_EVTOLUX_LUX_LUT
static uint32_t _calibration_evtolux_lux_lut[]
 = {18000,15000,10000,5000,2000,1000,800,500,200,100,50,10,1};

// CALIBRATION_BLACK_LEVEL_R
static uint16_t _calibration_black_level_r[][2] = {
  { 0, 270 },
  { 32, 270 },
  { 64, 270 },
  { 96, 270 },
  { 128, 270 }};

// CALIBRATION_BLACK_LEVEL_GR
static uint16_t _calibration_black_level_gr[][2] = {
  { 0, 270 },
  { 32, 270 },
  { 64, 270 },
  { 96, 270 },
  { 128, 270 }};

// CALIBRATION_BLACK_LEVEL_GB
static uint16_t _calibration_black_level_gb[][2] = {
  { 0, 270 },
  { 32, 270 },
  { 64, 270 },
  { 96, 270 },
  { 128, 270 }};

// CALIBRATION_BLACK_LEVEL_B
static uint16_t _calibration_black_level_b[][2] = {
  { 0, 270 },
  { 32, 270 },
  { 64, 270 },
  { 96, 270 },
  { 128, 270 }};

// CALIBRATION_STATIC_WB
static uint16_t _calibration_static_wb[]
 = {424,256,256,416};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_a_ccm[]
 = {390,32844,32826,32872,474,32882,32771,33071,562};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_d40_ccm[]
 = {414,32881,32813,32863,488,32905,0,33004,492};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_d50_ccm[]
 = {447,32923,32804,32842,489,32927,1,32953,440};

// CALIBRATION_SHADING_LS_A_R
static uint8_t _calibration_shading_ls_a_r[]
 = {169,151,137,126,117,109,103,98,94,90,87,84,82,81,81,80,80,80,81,83,85,88,91,94,98,104,109,117,126,136,150,168,163,146,134,123,114,107,101,96,91,88,85,83,80,79,79,78,78,78,79,81,83,86,88,92,96,101,107,114,123,133,146,162,157,142,130,120,111,104,98,93,89,86,83,81,79,77,76,76,76,77,77,79,81,83,86,89,94,99,105,111,120,130,142,158,153,139,126,117,108,102,96,91,87,84,81,79,77,76,75,74,74,75,76,77,79,81,84,87,92,96,102,109,117,127,138,153,149,135,124,114,106,100,94,89,85,82,79,77,75,74,73,73,73,73,74,75,77,80,82,86,90,94,100,106,114,124,135,148,146,132,121,112,104,98,92,88,84,80,78,76,74,73,72,71,71,72,73,74,76,78,81,84,88,92,98,105,112,121,132,145,143,130,119,110,102,96,90,86,82,79,76,74,72,71,71,70,70,70,71,72,74,77,79,83,86,90,96,103,110,119,130,142,140,127,117,108,100,94,89,84,81,78,75,73,71,70,69,69,69,69,70,71,73,75,78,81,85,89,95,101,108,117,127,140,139,126,115,107,99,93,88,83,80,77,74,72,70,69,68,68,67,68,69,70,72,74,77,80,84,88,93,100,107,115,125,138,137,125,114,105,98,92,87,82,79,76,73,71,69,68,67,67,66,67,68,69,71,73,76,79,83,87,92,98,105,113,123,136,135,123,112,104,97,91,86,81,78,75,72,70,68,67,66,65,65,66,67,68,70,72,75,78,82,86,91,97,104,112,122,134,133,122,112,103,96,90,85,80,77,74,72,69,67,66,65,65,65,65,66,68,70,72,74,77,81,85,90,96,103,111,121,133,133,121,111,102,95,90,84,80,77,74,71,69,67,66,65,64,64,64,65,67,69,71,74,77,80,85,89,95,102,111,120,131,132,120,111,102,95,89,84,80,77,73,71,68,66,65,64,64,64,64,65,66,68,71,74,77,80,84,89,95,101,110,120,131,132,120,110,102,94,89,84,80,76,73,70,68,66,65,64,64,64,64,65,66,68,71,73,76,80,84,89,95,101,109,119,131,131,120,110,102,95,89,84,79,76,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,80,84,89,95,101,109,119,131,132,120,110,101,94,89,84,79,76,73,70,68,66,65,64,64,64,64,65,66,68,71,73,76,80,84,89,95,101,109,119,130,132,120,110,102,95,89,84,80,76,73,70,68,66,65,64,64,64,64,65,66,68,71,73,76,80,84,89,95,101,109,119,131,133,120,110,102,95,89,84,80,77,73,71,69,67,65,65,64,64,64,65,67,69,71,74,77,80,84,89,95,102,110,120,132,134,121,111,103,96,90,84,80,77,74,71,69,67,66,65,64,64,65,66,67,69,72,74,77,80,84,90,96,102,111,120,133,135,122,112,103,97,91,85,81,78,74,72,70,68,66,66,65,65,65,66,68,70,72,74,78,81,85,90,96,103,111,121,133,136,123,113,105,97,91,86,81,78,75,72,70,68,67,66,66,66,66,67,68,70,73,75,78,82,86,91,97,104,113,122,134,137,125,115,106,98,92,87,83,79,76,73,71,69,68,67,67,67,67,68,69,71,74,76,79,83,87,92,98,105,114,124,136,140,127,116,107,100,94,88,84,80,77,75,72,70,69,69,68,68,68,69,71,72,75,77,80,84,88,94,100,106,116,125,138,142,129,118,109,102,95,90,85,82,78,76,73,72,70,69,69,69,69,70,72,73,76,78,82,85,90,95,101,108,117,128,140,146,132,120,111,103,97,91,87,83,79,77,75,73,72,71,70,70,71,71,73,75,77,80,83,87,91,97,103,110,119,130,144,149,135,123,113,105,98,93,88,84,81,78,76,74,73,72,72,72,72,73,74,76,78,81,84,88,93,99,105,112,122,132,146,152,138,126,116,107,101,95,90,86,83,80,78,76,75,74,73,73,74,74,76,78,80,83,86,90,95,101,107,115,124,136,150,157,141,129,119,110,103,98,92,88,85,82,80,78,76,75,75,75,75,76,77,79,82,85,88,92,97,103,109,117,127,140,154,163,146,133,122,113,106,100,94,91,87,84,82,80,78,78,77,77,77,78,79,81,84,86,90,94,99,105,112,121,131,143,159,168,150,136,125,116,108,102,96,92,89,86,83,81,80,79,79,79,79,80,81,83,86,88,92,96,102,108,115,124,135,148,164,172,154,140,128,119,111,104,99,94,91,88,85,83,82,81,81,80,80,81,83,85,87,90,94,98,104,110,118,127,138,152,170};

// CALIBRATION_SHADING_LS_A_G
static uint8_t _calibration_shading_ls_a_g[]
  = {159,144,132,122,114,108,102,97,93,90,87,85,83,81,81,80,80,81,81,83,85,87,90,93,97,103,108,115,123,133,144,158,155,140,129,119,111,105,99,95,91,88,85,83,81,79,79,78,78,79,80,81,83,85,88,91,95,100,105,112,120,129,140,153,151,137,125,116,109,102,97,92,89,85,83,80,79,77,77,76,76,77,78,79,81,83,86,89,93,97,103,109,117,126,136,149,146,133,122,113,106,100,95,90,86,83,81,79,77,76,75,74,75,75,76,77,79,81,84,87,91,95,101,107,114,123,133,145,142,130,120,111,104,98,93,88,85,82,79,77,75,74,73,73,73,73,74,75,77,79,82,85,89,93,98,104,112,120,130,142,139,127,117,109,102,96,91,86,83,80,78,75,74,72,72,71,71,72,73,74,76,78,80,84,87,91,97,103,110,118,127,139,136,125,115,107,100,94,89,85,82,79,76,74,72,71,70,70,70,70,71,73,74,77,79,82,86,90,95,101,107,115,125,137,134,123,113,106,99,93,88,84,81,78,75,73,71,70,69,69,69,69,70,71,73,75,78,81,85,88,93,99,106,114,123,134,132,121,112,104,97,92,87,83,80,77,74,72,70,69,68,68,68,68,69,70,72,74,77,80,83,87,92,98,104,112,121,133,130,120,110,103,96,91,86,82,79,76,73,71,69,68,67,66,66,67,68,69,71,73,76,79,82,86,91,96,103,111,120,131,129,118,109,102,95,90,85,81,78,75,72,70,68,67,66,65,65,66,67,68,70,72,75,78,81,85,90,95,102,109,118,129,128,117,108,101,95,89,84,80,77,74,72,69,67,66,65,65,65,65,66,68,69,72,74,77,81,84,89,94,100,108,117,128,127,116,108,100,94,88,84,80,76,74,71,69,67,66,65,64,64,65,65,67,69,71,74,77,80,84,88,94,100,108,116,127,126,116,107,100,93,88,83,79,76,73,70,68,67,65,64,64,64,64,65,66,68,71,73,76,80,83,88,93,100,107,116,127,126,115,107,99,93,88,83,79,76,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,83,88,93,99,106,116,126,125,115,107,99,93,87,83,79,76,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,83,88,93,99,107,115,126,126,115,107,99,93,87,83,79,76,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,83,88,93,99,107,115,126,126,116,107,99,93,88,83,79,76,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,83,88,93,99,107,116,126,127,116,107,100,93,88,83,79,76,73,71,68,67,65,65,64,64,64,65,67,69,71,73,76,80,83,88,93,100,107,116,126,127,116,108,100,94,88,84,80,76,74,71,69,67,66,65,64,64,65,66,67,69,71,74,77,80,84,88,94,100,108,117,127,128,118,109,101,94,89,84,80,77,74,72,69,68,66,65,65,65,65,66,68,70,72,74,77,81,84,89,94,101,109,117,128,129,118,110,102,95,90,85,81,78,75,72,70,68,67,66,66,66,66,67,68,70,73,75,78,81,85,90,95,102,109,118,129,131,120,111,103,96,91,86,82,79,76,73,71,69,68,67,67,67,67,68,69,71,73,76,79,82,86,91,96,103,111,120,130,133,122,112,104,98,92,87,83,80,77,74,72,70,69,68,68,68,68,69,70,72,74,77,80,83,87,92,98,104,112,121,132,136,124,114,106,99,93,89,84,81,78,75,73,71,70,69,69,69,69,70,71,73,75,78,81,85,88,93,99,106,114,123,134,138,126,116,108,100,95,90,85,82,79,76,74,73,71,71,70,70,71,71,73,74,77,79,82,86,90,95,101,108,116,125,137,140,128,118,110,102,97,91,87,83,80,78,76,74,73,72,71,72,72,73,74,76,78,80,84,87,91,97,103,109,117,128,140,144,131,121,112,105,98,93,89,85,82,79,77,76,74,73,73,73,73,74,75,77,79,82,85,89,93,98,104,111,120,130,143,148,134,123,114,107,100,95,91,87,84,81,79,77,76,75,75,75,75,76,77,79,81,84,87,91,95,100,106,114,123,133,146,152,138,126,117,109,103,97,93,89,86,83,81,79,78,77,76,77,77,78,79,81,83,86,89,93,98,103,109,117,126,137,150,157,142,130,120,112,105,100,95,91,88,85,83,81,80,79,78,78,79,80,81,83,85,88,91,95,100,105,112,120,129,141,155,161,146,134,123,115,108,102,97,93,90,87,85,83,82,81,80,80,81,81,83,85,87,90,93,98,102,108,115,123,133,145,160};

// CALIBRATION_SHADING_LS_A_B
static uint8_t _calibration_shading_ls_a_b[]
  = {157,142,131,120,113,106,101,96,92,89,86,84,82,81,80,80,80,80,81,82,85,87,90,93,97,101,106,112,121,130,143,158,152,138,127,118,110,104,99,94,90,87,84,82,80,79,78,78,78,78,79,81,82,84,87,90,94,99,104,110,118,128,139,154,149,135,123,115,107,102,96,92,88,85,82,80,78,77,76,76,76,76,77,78,80,82,85,88,92,97,102,109,116,125,136,149,144,131,121,112,105,99,94,90,86,83,80,78,76,75,74,74,74,74,75,77,78,81,83,86,90,95,100,106,113,122,133,145,141,129,118,110,103,97,92,88,84,81,78,76,75,74,73,72,72,73,73,75,77,79,81,84,88,92,98,104,111,119,129,141,138,126,116,108,101,95,90,86,82,80,77,75,73,72,72,71,71,72,72,74,75,78,80,83,86,90,96,102,109,117,126,138,135,124,114,106,100,94,89,85,81,78,76,74,72,71,70,70,70,70,71,72,74,76,79,82,85,89,94,100,107,115,124,136,133,121,112,105,98,92,87,84,80,77,75,73,71,70,69,68,68,69,70,71,73,75,77,81,84,87,93,99,105,113,122,134,132,121,111,103,97,91,86,82,79,76,74,72,70,69,68,68,67,68,68,70,71,74,76,79,83,87,91,97,103,111,121,133,130,119,110,102,95,90,85,81,78,75,73,71,69,68,67,66,66,67,68,69,71,73,76,78,82,86,90,96,102,110,119,131,128,117,108,101,94,89,85,81,77,74,72,70,68,67,66,65,65,66,67,68,70,72,75,78,81,85,89,95,101,108,117,129,127,117,108,100,94,88,84,80,77,74,71,69,67,66,65,65,65,65,66,67,69,71,74,77,80,84,88,94,100,108,117,128,126,116,107,99,93,88,83,80,76,73,71,68,67,65,65,64,64,65,65,67,69,71,73,76,80,84,88,93,100,107,116,127,125,115,107,99,93,88,83,79,76,73,70,68,67,65,65,64,64,64,65,66,68,71,73,76,79,83,88,93,99,106,115,125,124,115,107,99,92,87,82,79,75,72,70,68,66,65,65,64,64,64,65,66,68,70,73,76,79,83,87,93,98,106,115,125,125,114,106,99,92,87,82,78,75,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,83,87,93,99,106,115,126,125,115,106,98,92,87,82,79,75,72,70,68,66,65,64,64,64,64,65,66,68,70,72,76,79,83,87,93,98,106,115,126,126,116,106,99,92,87,83,78,75,73,70,68,66,65,64,64,64,64,65,67,68,70,73,76,79,83,87,93,99,106,116,127,126,115,107,99,93,87,82,79,76,73,70,68,67,65,64,64,64,65,65,67,68,71,73,76,79,83,87,93,99,107,115,126,127,116,107,99,93,87,83,79,76,73,71,68,67,66,65,65,64,65,66,67,69,71,74,76,80,83,88,93,99,107,115,126,127,117,108,100,94,88,84,80,77,74,71,69,68,66,65,65,65,65,66,68,70,72,74,77,80,84,88,94,100,108,116,126,129,118,108,101,95,89,84,80,77,74,72,70,68,67,66,66,66,66,67,68,70,72,75,78,81,84,89,95,101,109,117,127,130,119,109,102,96,90,85,82,78,76,73,71,69,68,67,67,67,67,68,69,71,73,76,79,82,85,90,96,102,110,119,129,132,121,111,104,96,91,86,83,79,76,74,72,70,69,68,67,68,68,69,70,72,74,76,80,83,87,91,97,103,111,121,131,134,122,112,104,97,92,88,83,80,77,74,73,71,70,69,69,69,69,70,71,73,75,77,80,84,88,93,98,105,113,122,133,135,124,114,106,100,94,89,85,81,78,76,74,73,71,70,70,70,70,71,73,74,76,78,81,85,89,94,100,106,114,124,135,138,126,116,108,101,95,90,86,83,80,77,75,73,72,71,71,71,71,72,73,75,77,80,83,87,91,96,101,108,116,126,138,141,128,119,110,103,97,92,88,84,81,79,77,75,74,73,73,73,73,74,75,77,79,81,84,88,92,97,103,110,118,128,140,146,133,121,113,106,99,94,90,86,83,80,78,77,75,75,74,74,75,75,76,78,80,83,86,90,94,100,105,112,121,131,144,150,135,125,115,108,101,96,92,88,85,82,80,78,77,76,76,76,76,77,78,80,82,84,88,92,96,102,107,114,124,135,148,152,138,127,118,110,103,98,93,90,87,84,82,80,79,78,78,78,77,78,79,82,84,87,89,94,98,104,110,117,126,138,153,156,142,130,121,112,106,100,95,92,88,86,83,82,80,80,79,79,79,79,81,83,86,88,91,95,100,106,112,120,129,141,156};

// CALIBRATION_SHADING_LS_TL84_R
static uint8_t _calibration_shading_ls_tl84_r[]
= {168,150,137,125,117,109,104,98,93,90,87,84,83,81,81,80,80,80,81,83,85,88,90,94,98,103,109,116,125,136,150,167,162,146,133,122,114,107,101,96,91,88,85,83,81,80,79,79,78,78,79,81,83,86,88,92,96,101,107,114,123,133,146,162,158,142,129,120,111,104,98,93,89,86,83,81,79,78,77,76,77,77,78,79,81,84,86,90,94,99,105,112,120,129,142,157,153,138,126,116,109,102,96,91,87,84,81,79,77,76,75,75,74,75,76,77,79,82,84,88,92,97,103,109,117,127,138,152,149,135,124,114,106,100,94,89,86,82,79,77,75,74,73,73,73,73,74,75,77,80,82,86,90,94,100,107,115,124,135,149,145,132,121,112,104,98,92,88,84,81,78,75,74,73,72,71,72,72,73,74,76,78,81,84,88,92,98,104,112,121,132,145,142,129,119,110,102,95,91,86,82,79,76,74,72,71,70,70,70,70,71,72,74,77,80,83,87,91,96,103,110,119,129,142,141,127,116,108,101,94,89,85,81,78,75,73,71,70,69,69,69,69,70,71,73,75,78,81,85,89,95,101,108,117,127,140,137,125,115,107,99,93,87,83,80,77,74,72,70,69,68,68,67,68,69,70,72,74,77,80,84,88,93,100,106,115,125,138,136,123,114,105,98,92,87,82,79,76,73,71,69,68,67,67,66,67,68,69,71,74,76,79,83,87,92,98,105,114,124,136,133,122,113,104,97,91,85,82,78,75,72,70,68,67,66,65,65,66,67,68,70,73,75,78,82,86,91,97,104,112,122,134,133,121,112,104,96,90,84,81,78,74,72,69,67,66,65,65,65,65,66,67,70,72,74,77,81,85,90,96,102,111,121,133,132,120,111,103,96,90,84,80,77,74,71,69,67,66,65,64,64,65,65,67,69,71,74,77,80,84,89,95,102,110,120,132,132,120,110,102,95,89,84,80,77,74,71,68,67,65,64,64,64,64,65,67,69,71,74,76,80,84,89,95,102,110,119,131,131,120,109,102,95,89,84,80,76,73,70,68,66,65,64,64,64,64,65,66,68,71,73,76,80,84,89,94,101,109,119,131,131,119,110,101,95,89,84,79,76,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,83,88,95,101,109,119,131,131,119,110,101,94,89,83,79,76,73,70,68,66,65,64,64,64,64,65,66,68,71,73,76,80,83,89,94,101,109,119,130,132,120,110,102,95,89,84,80,76,73,70,68,66,65,64,64,64,64,65,66,68,71,73,76,80,84,89,94,101,109,119,130,132,120,110,102,95,89,84,80,76,73,71,69,67,65,65,64,64,64,65,67,69,71,74,76,80,84,89,95,102,110,119,130,133,121,111,103,95,89,85,80,77,74,71,69,67,66,65,64,64,65,66,67,69,71,74,77,81,84,89,95,102,110,120,131,134,122,112,104,96,90,85,81,78,74,72,70,68,66,65,65,65,65,66,68,70,72,74,77,81,85,90,96,103,111,121,133,136,124,113,104,97,92,86,82,79,75,72,70,68,67,66,66,66,66,67,68,70,73,75,78,82,86,91,97,104,112,122,134,138,125,114,106,99,93,87,83,79,76,73,71,69,68,67,67,67,67,68,69,71,74,76,79,83,87,92,98,105,114,124,136,140,127,116,107,100,94,88,84,80,77,74,72,70,69,68,68,68,68,69,70,72,74,77,80,84,88,93,99,106,115,125,138,142,129,118,109,102,95,90,85,81,79,76,73,72,70,70,69,69,69,70,71,73,75,78,82,85,89,94,101,108,117,127,140,145,131,121,111,103,97,91,87,83,79,77,74,73,72,71,70,70,71,71,73,75,77,80,83,86,91,96,102,110,119,130,143,149,135,122,113,105,99,93,88,85,81,78,76,74,73,72,72,72,72,73,74,76,78,81,84,88,93,98,104,112,121,132,146,153,138,126,115,107,101,95,90,86,83,80,78,76,75,74,73,73,73,74,76,77,80,83,86,90,94,100,107,114,124,135,149,157,141,129,118,110,103,97,92,88,85,82,79,78,77,76,75,75,75,76,78,79,82,84,87,92,97,102,109,117,127,139,153,160,144,132,122,113,106,100,94,91,87,84,81,79,78,78,77,77,77,78,79,81,84,87,90,94,99,105,111,120,131,142,157,167,150,135,124,116,108,101,97,92,89,86,83,81,80,79,79,79,79,80,81,83,85,88,92,96,102,107,114,123,134,147,162,174,154,139,127,118,110,104,99,94,91,87,85,83,82,81,80,80,80,81,83,84,87,89,93,98,104,110,117,126,138,152,168};

// CALIBRATION_SHADING_LS_TL84_G
static uint8_t _calibration_shading_ls_tl84_g[]
= {159,144,132,121,114,107,102,97,93,90,87,85,83,82,81,80,80,81,82,83,85,87,90,93,98,102,108,115,123,133,144,159,154,140,128,119,111,105,99,94,91,88,85,83,81,80,79,78,78,79,80,81,83,85,88,91,95,100,105,112,119,129,140,154,150,136,125,116,108,102,97,92,88,85,83,80,79,77,77,76,76,77,78,79,81,83,86,89,93,97,103,109,117,126,136,149,145,133,122,113,106,100,95,90,87,83,81,79,77,76,75,75,74,75,76,77,79,81,84,87,91,95,100,107,114,122,133,145,141,129,119,111,104,98,93,88,85,82,79,77,75,74,73,73,73,73,74,75,77,79,82,85,89,93,98,104,111,120,130,142,138,127,117,109,102,96,91,87,83,80,77,75,74,73,72,71,71,72,73,74,76,78,81,84,87,91,97,103,109,118,127,139,136,124,115,107,100,94,89,85,82,79,76,74,72,71,70,70,70,70,71,72,74,76,79,82,86,90,95,100,107,115,125,136,134,122,113,105,98,93,88,84,81,78,75,73,71,70,69,69,69,69,70,71,73,75,78,81,84,88,93,99,106,113,123,134,131,121,112,104,97,92,87,83,80,77,74,72,70,69,68,68,67,68,69,70,72,74,77,80,83,87,92,97,104,112,121,132,130,119,110,102,96,91,86,82,78,76,73,71,69,68,67,66,66,67,68,69,71,73,76,79,82,86,90,96,103,110,119,131,128,118,109,102,95,90,85,81,78,75,72,70,68,67,66,65,66,66,67,68,70,72,75,78,81,85,89,95,101,109,118,129,127,117,108,101,94,89,84,80,77,74,72,69,68,66,65,65,65,65,66,67,69,72,74,77,80,84,89,94,100,108,117,128,127,116,108,100,94,88,84,80,77,74,71,69,67,66,65,64,64,65,65,67,69,71,74,77,80,83,88,94,100,107,116,127,126,116,107,99,93,88,83,79,76,73,71,68,66,65,64,64,64,64,65,67,68,71,73,76,80,83,88,93,99,107,115,126,126,115,106,99,93,88,83,79,76,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,83,87,93,99,106,115,125,125,115,106,99,93,87,82,79,76,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,82,87,92,99,106,115,125,126,115,106,99,93,87,83,79,76,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,83,87,93,99,106,115,125,126,116,107,99,93,88,83,79,76,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,83,87,93,99,106,115,126,127,116,107,100,93,88,83,79,76,73,71,68,67,65,64,64,64,64,65,67,68,71,73,76,79,83,87,93,99,107,115,126,127,117,108,100,94,88,84,80,77,74,71,69,67,66,65,64,64,65,66,67,69,71,74,76,80,83,88,93,100,107,116,126,128,117,108,101,94,89,84,80,77,74,71,69,68,66,65,65,65,65,66,68,69,72,74,77,80,84,88,94,100,108,117,127,129,118,109,102,95,90,85,81,78,75,72,70,68,67,66,66,66,66,67,68,70,72,75,78,81,84,89,95,101,109,118,128,131,120,111,103,96,91,86,82,79,76,73,71,69,68,67,67,67,67,68,69,71,73,76,78,82,86,90,96,102,110,119,130,133,122,112,104,98,92,87,83,80,77,74,72,70,69,68,68,68,68,69,70,72,74,77,80,83,87,92,97,104,112,121,132,136,124,114,106,99,93,88,84,81,78,75,73,71,70,69,69,69,69,70,71,73,75,78,81,84,88,93,99,105,113,122,133,138,126,116,108,101,95,90,85,82,79,76,74,73,71,71,70,70,70,71,73,74,76,79,82,86,90,95,100,107,115,124,135,141,128,118,110,103,97,92,87,84,80,78,76,74,73,72,71,72,72,73,74,76,78,80,83,87,91,96,102,109,117,127,138,144,131,120,112,105,99,93,89,85,82,79,77,76,74,73,73,73,73,74,75,77,79,82,85,89,93,98,104,111,119,129,142,147,134,123,114,107,100,95,91,87,84,81,79,77,76,75,75,75,75,76,77,79,81,83,87,90,95,100,106,113,122,133,145,152,138,126,117,109,103,98,93,89,86,83,81,79,78,77,77,76,77,78,79,81,83,85,89,93,97,102,108,116,125,136,150,156,142,130,120,112,105,100,95,91,88,85,83,81,80,79,78,78,79,79,81,83,85,88,91,95,100,105,111,119,129,140,154,161,146,134,123,115,108,102,97,93,90,87,85,83,82,81,80,80,80,81,83,84,87,90,93,97,102,107,114,122,133,144,159};

// CALIBRATION_SHADING_LS_TL84_B
static uint8_t _calibration_shading_ls_tl84_b[]
  =  {155,141,130,120,112,105,100,96,92,89,86,84,82,81,80,80,79,80,81,82,84,86,89,93,97,101,106,113,121,131,142,157,151,137,126,117,110,103,98,94,90,87,84,82,80,79,78,78,78,78,79,80,82,84,87,90,94,98,104,110,118,127,139,153,147,134,123,114,107,101,96,91,88,84,82,80,78,77,76,76,76,76,77,79,80,82,85,88,92,96,101,108,115,124,135,149,143,131,120,112,105,99,94,90,86,83,80,78,76,75,75,74,74,74,75,76,78,80,83,86,90,94,100,105,113,121,132,144,140,128,118,110,103,97,92,88,84,81,78,76,75,74,73,72,72,73,74,75,76,79,81,84,88,92,98,103,110,119,128,140,136,125,115,107,101,95,90,86,82,80,77,75,74,72,71,71,71,72,72,74,75,78,80,83,86,90,96,102,108,116,126,137,134,123,113,105,99,94,88,84,81,78,76,74,72,71,70,70,70,70,71,72,74,76,79,82,85,89,94,100,106,114,124,135,131,121,112,104,97,92,87,83,80,78,75,73,71,70,69,68,69,69,70,71,73,75,77,81,84,87,93,98,105,113,122,134,130,119,110,102,96,91,86,82,79,76,74,72,70,69,68,67,67,68,68,70,72,74,76,79,83,86,91,97,103,111,121,132,128,118,109,101,96,90,85,81,78,75,73,71,69,68,67,67,67,67,68,69,71,73,75,78,82,85,90,95,102,109,119,130,128,117,107,100,94,89,84,80,77,74,72,70,68,67,66,66,66,66,67,68,70,72,74,77,81,84,89,94,100,108,117,127,126,116,107,100,93,88,83,80,77,74,71,69,68,66,66,65,65,65,66,67,69,71,74,77,80,84,88,94,99,107,116,126,126,115,107,99,92,88,83,79,76,73,71,69,67,65,65,65,64,65,65,67,69,71,73,76,80,83,88,93,99,107,116,126,125,115,105,99,92,87,83,79,76,73,70,68,67,65,65,64,64,65,65,67,68,71,73,76,79,83,87,93,99,106,115,125,125,114,105,98,92,87,82,78,75,73,70,68,66,65,64,64,64,64,65,66,68,70,72,76,79,82,87,92,98,105,114,124,124,114,106,98,92,86,82,78,75,72,70,68,66,65,64,64,64,64,65,66,68,70,73,75,79,82,87,92,98,105,114,124,124,114,105,98,92,86,82,78,75,72,70,68,66,65,64,64,64,64,65,66,68,70,72,75,79,82,87,92,98,105,114,124,124,114,105,98,92,86,82,78,75,73,70,68,66,65,64,64,64,64,65,66,68,70,73,75,79,82,87,92,98,105,114,124,124,114,106,98,92,87,83,79,75,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,82,87,93,98,105,114,124,125,115,106,99,93,88,83,79,76,73,71,69,67,66,65,64,64,65,65,67,68,71,73,76,79,82,87,93,99,106,115,125,126,116,107,100,93,88,83,79,77,74,71,69,67,66,65,65,65,65,66,67,69,71,73,77,80,83,88,93,100,107,115,126,127,117,108,100,94,89,84,80,77,74,72,70,68,67,66,66,65,66,66,68,70,72,74,77,80,84,89,94,100,108,117,127,128,118,109,101,95,90,85,81,78,75,73,71,69,68,67,67,66,66,68,69,71,73,75,78,81,85,90,95,101,109,118,128,130,120,111,103,96,91,86,82,79,76,74,72,70,69,68,67,67,68,68,70,72,74,76,79,82,86,91,96,102,110,119,130,133,122,112,105,98,92,87,83,80,77,75,73,71,70,69,69,68,69,70,71,73,74,77,80,83,87,92,97,103,111,121,132,136,124,114,106,99,94,89,85,81,78,76,74,72,71,70,70,70,70,71,72,74,76,78,81,85,88,93,99,105,114,123,134,139,126,115,108,101,95,91,86,83,80,77,75,73,72,71,71,71,71,72,73,75,77,79,82,86,90,95,101,107,115,125,137,141,128,118,110,103,97,92,88,84,81,79,76,75,74,73,72,72,73,74,75,76,78,81,84,88,92,97,102,109,117,128,140,144,131,121,112,105,99,94,89,86,83,80,78,76,76,75,74,74,74,75,76,78,80,83,86,89,94,99,104,111,120,130,143,148,134,123,114,107,101,96,92,88,84,82,80,78,77,76,76,75,76,76,78,79,82,84,87,91,95,101,107,114,122,133,146,151,138,126,118,110,103,98,93,90,86,84,81,80,79,78,77,77,77,78,79,81,83,86,89,93,97,103,109,117,125,136,150,156,141,130,121,113,106,100,95,91,88,85,83,81,80,80,79,79,79,80,81,83,85,88,91,95,99,104,111,119,128,139,154};

// CALIBRATION_SHADING_LS_D65_R
static uint8_t _calibration_shading_ls_d65_r[]
 = {166,150,136,126,117,109,103,98,93,90,87,84,82,81,81,80,80,80,81,83,85,87,90,94,98,103,108,116,124,135,148,163,161,145,133,122,114,107,100,96,91,88,85,83,81,80,79,78,78,79,80,81,83,85,88,91,95,100,106,113,121,132,143,158,156,141,129,119,111,104,98,93,89,86,83,81,79,78,77,77,77,77,78,79,81,83,86,89,93,97,103,110,119,128,140,154,152,137,126,116,108,102,96,91,87,84,81,79,77,76,75,75,75,75,76,77,79,81,84,87,91,96,102,108,116,125,136,150,148,134,123,113,106,99,94,90,86,82,80,78,76,74,73,73,73,73,74,75,77,79,82,85,90,93,99,105,112,122,132,146,145,131,120,111,104,98,92,88,84,80,78,76,74,73,72,72,71,72,73,74,75,78,80,84,87,92,97,103,110,119,130,143,142,129,118,109,102,96,91,86,82,79,77,74,72,72,71,70,70,70,71,72,74,76,79,82,86,90,95,101,109,117,128,141,139,126,116,108,101,94,89,85,81,78,75,73,72,70,70,69,69,69,70,71,73,75,78,81,84,89,94,100,107,115,125,138,137,124,115,106,99,93,88,84,80,77,74,72,70,69,68,67,68,68,69,70,72,74,77,80,83,88,92,98,105,113,123,135,135,123,113,105,98,92,87,82,79,76,73,71,69,68,67,67,66,67,68,69,71,73,75,78,82,86,91,97,104,112,122,133,133,122,112,104,97,91,86,82,78,75,73,70,69,67,66,66,65,66,67,68,70,72,74,78,81,85,90,96,103,111,120,131,131,121,112,103,96,91,85,81,77,75,72,70,68,66,65,65,65,65,66,68,69,72,74,77,81,84,89,95,102,110,119,130,131,120,111,102,96,90,85,80,77,74,71,69,67,66,65,65,64,65,65,67,69,71,73,76,80,84,89,95,101,109,118,129,130,119,110,102,95,89,84,80,76,74,71,69,67,66,65,64,64,64,65,67,68,70,73,76,79,83,88,94,100,108,117,128,131,119,109,102,95,89,84,80,76,73,71,68,66,65,64,64,64,64,65,66,68,70,73,76,79,83,88,93,100,108,117,127,130,119,110,101,95,89,84,79,76,73,71,68,66,65,65,64,64,64,65,66,68,70,73,76,79,82,87,93,99,107,116,127,131,119,110,102,95,88,84,79,76,73,71,68,66,65,65,64,64,64,65,66,68,70,72,76,79,83,87,93,99,107,117,128,131,119,109,101,95,89,84,79,76,73,70,68,66,65,64,64,64,64,65,66,68,70,73,76,79,82,88,93,100,108,117,128,132,120,110,102,95,89,84,80,76,74,71,68,67,65,64,64,64,64,65,67,68,70,73,76,79,83,88,93,100,108,117,129,132,120,111,103,96,90,85,80,77,74,71,69,67,66,65,64,64,64,66,67,69,71,73,76,79,83,88,93,100,108,118,129,132,121,112,103,97,90,85,81,77,75,72,70,68,67,66,65,65,65,66,68,69,71,74,77,80,84,89,94,101,109,118,130,133,122,113,104,97,91,86,82,78,75,73,71,69,67,66,66,66,66,67,69,70,72,74,77,81,85,90,95,102,110,119,130,136,124,114,106,99,93,87,83,79,76,73,71,69,68,67,67,67,67,68,69,71,73,75,78,82,86,91,97,103,111,121,132,139,126,116,107,100,94,88,84,80,77,75,73,71,69,68,68,68,68,69,70,72,74,76,79,83,87,92,97,105,113,122,134,141,128,118,109,102,95,90,85,81,78,76,73,72,70,69,69,69,69,70,71,73,75,78,81,84,88,93,99,106,115,124,136,144,130,120,111,103,97,91,87,83,80,77,75,73,72,71,70,70,71,71,72,74,76,79,82,85,90,95,101,108,116,126,138,146,133,122,113,105,99,92,88,84,81,78,76,75,73,72,72,71,72,72,74,76,78,80,83,87,91,96,102,110,118,128,141,151,136,125,115,107,100,95,90,86,83,80,77,76,75,74,73,73,73,74,75,77,79,82,85,89,93,98,104,112,121,132,145,156,141,128,118,110,103,97,92,88,85,82,79,78,76,75,75,74,75,76,77,79,81,83,87,91,95,101,107,115,124,135,148,161,144,132,121,113,106,100,94,90,87,84,82,80,78,77,77,77,77,78,79,81,83,86,89,93,98,103,110,118,127,139,153,164,147,135,124,115,108,101,96,92,89,86,83,81,80,79,79,78,79,80,81,82,85,87,91,95,100,105,112,121,131,143,158,167,151,138,127,118,110,103,98,94,90,88,85,83,81,80,80,80,81,81,82,84,86,89,92,97,102,107,114,124,134,147,163};

// CALIBRATION_SHADING_LS_D65_G
static uint8_t _calibration_shading_ls_d65_g[]
  = {157,143,131,122,114,107,101,97,93,89,87,85,83,81,80,80,80,80,81,83,84,86,89,93,97,101,107,113,121,131,142,155,153,139,128,118,111,104,99,95,90,87,85,83,81,79,79,78,78,78,79,81,82,85,87,91,94,99,104,110,118,127,138,151,148,135,124,115,108,102,97,92,88,85,83,80,79,77,77,76,76,77,77,79,80,82,85,88,92,96,102,108,115,124,134,147,144,132,121,113,106,100,94,90,86,84,81,79,77,76,75,74,74,75,76,77,79,81,83,86,90,94,99,105,112,121,131,143,141,129,119,111,104,98,93,88,85,82,79,77,75,74,73,73,73,73,74,75,77,79,82,84,88,92,97,103,110,118,128,140,138,126,116,109,102,96,91,87,83,80,78,75,74,73,72,71,71,72,72,74,75,77,80,83,87,91,96,101,108,116,125,137,136,124,114,107,100,94,89,85,82,79,76,74,72,71,70,70,70,70,71,72,74,76,78,82,85,89,94,99,106,114,123,134,133,122,113,105,99,93,88,84,80,78,75,73,71,70,69,69,69,69,70,71,73,75,77,80,84,87,92,98,104,112,121,132,131,120,111,104,97,92,87,83,79,77,74,72,70,69,68,68,67,68,69,70,72,74,76,79,82,86,91,96,103,110,119,130,129,119,110,102,96,91,86,82,78,76,73,71,69,68,67,66,66,67,68,69,71,73,75,78,81,85,90,95,102,109,118,129,127,117,109,102,95,90,85,81,77,75,72,70,68,67,66,66,66,66,67,68,70,72,74,77,80,84,89,94,100,108,117,127,127,116,108,101,95,89,84,80,77,74,72,70,68,66,65,65,65,65,66,67,69,71,74,77,80,83,88,93,99,106,115,126,126,116,107,100,94,88,84,80,76,74,71,69,67,66,65,64,64,65,65,67,69,71,73,76,79,83,87,92,99,106,114,125,125,115,107,100,94,88,83,79,76,73,71,68,67,65,65,64,64,64,65,66,68,70,73,76,79,82,87,92,98,105,114,124,125,115,107,99,93,88,83,79,75,73,70,68,66,65,64,64,64,64,65,66,68,70,72,75,78,82,86,92,98,105,113,123,125,115,106,99,93,87,83,79,75,73,70,68,66,65,64,64,64,64,65,66,68,70,72,75,78,82,86,91,97,105,113,123,125,115,106,99,93,87,83,79,75,73,70,68,66,65,64,64,64,64,65,66,68,70,72,75,78,82,86,91,97,105,113,122,125,115,107,99,93,88,83,79,75,73,70,68,66,65,64,64,64,64,65,66,68,70,72,75,78,82,86,91,97,105,113,123,126,115,107,100,93,88,83,79,76,73,71,68,67,65,64,64,64,64,65,66,68,70,72,75,79,82,87,92,98,105,114,123,127,116,108,100,94,88,84,80,76,74,71,69,67,66,65,64,64,65,65,67,69,71,73,76,79,83,87,92,98,106,114,124,128,117,108,101,95,89,84,80,77,74,72,69,68,66,65,65,65,65,66,67,69,71,73,76,80,83,88,93,99,106,115,124,129,118,110,102,96,90,85,81,77,75,72,70,68,67,66,66,66,66,67,68,70,72,74,77,80,84,88,94,100,107,116,126,131,120,111,103,97,91,86,82,78,76,73,71,69,68,67,67,67,67,68,69,71,73,75,78,81,85,89,95,101,109,117,127,132,121,112,104,98,92,87,83,79,77,74,72,70,69,68,68,68,68,69,70,72,74,76,79,82,86,91,96,102,110,119,129,135,123,114,106,99,93,88,84,81,78,75,73,71,70,69,69,69,69,70,71,73,75,77,80,83,87,92,97,104,111,120,131,137,125,116,108,101,95,90,86,82,79,76,74,73,72,70,70,70,70,71,72,74,76,78,81,85,88,93,98,105,113,122,133,140,128,117,110,103,97,92,87,84,80,78,76,74,73,72,71,71,71,72,73,75,77,80,83,86,90,95,100,107,115,124,136,143,131,120,112,105,99,93,89,85,82,80,77,76,74,73,73,73,73,74,75,77,79,81,84,88,92,97,102,109,117,127,139,147,134,123,114,107,101,95,91,87,84,81,79,77,76,75,74,74,75,76,77,78,80,83,86,90,94,99,105,112,120,130,142,151,137,126,117,110,103,97,93,89,86,83,81,79,78,77,76,76,77,77,79,80,82,85,88,92,96,101,107,114,123,133,146,156,141,130,120,113,106,100,95,91,88,85,83,81,80,79,78,78,79,79,81,82,84,87,90,94,98,103,110,117,126,137,150,161,146,134,123,115,108,102,97,93,90,87,85,83,82,81,80,80,80,81,82,84,87,89,92,96,101,106,113,121,130,141,155};

// CALIBRATION_SHADING_LS_D65_B
static uint8_t _calibration_shading_ls_d65_b[]
 = {153,140,129,119,113,106,100,95,91,88,85,84,82,80,80,79,79,80,80,82,84,86,88,92,96,100,105,111,119,129,139,152,149,136,126,116,110,104,98,93,89,86,84,82,80,79,78,78,78,78,79,80,82,84,86,90,94,98,103,109,116,126,136,150,145,133,123,114,107,101,96,91,88,84,82,80,78,77,76,76,76,76,77,78,80,82,84,87,91,96,101,107,114,123,133,147,142,130,120,112,105,99,93,89,86,83,80,78,76,76,74,74,74,74,75,76,78,80,83,86,90,94,99,104,111,119,130,143,139,127,117,109,103,97,92,88,84,81,78,76,75,74,73,73,72,73,74,75,76,78,81,84,88,92,97,102,109,117,127,139,136,125,115,108,101,95,90,86,83,80,77,75,73,72,71,71,71,71,72,73,75,77,80,83,86,90,95,100,107,115,124,136,133,122,113,105,99,93,89,85,81,78,76,74,72,71,70,70,70,70,71,72,74,76,78,81,84,88,93,98,105,113,122,133,131,121,112,104,98,92,87,83,80,77,75,73,71,70,69,69,68,69,70,71,73,75,77,80,83,87,92,97,103,111,120,131,129,119,110,103,96,91,86,82,79,76,74,72,70,69,68,67,67,68,69,70,72,73,76,79,82,86,91,96,102,110,119,129,127,117,109,101,95,90,85,81,78,75,73,71,69,68,67,66,66,67,67,69,71,73,75,78,81,85,89,95,101,108,117,128,126,116,108,101,95,89,84,81,77,75,72,70,68,67,66,66,65,66,67,68,70,72,74,77,80,84,89,93,100,107,116,126,125,115,107,100,94,88,84,80,77,74,72,69,68,66,65,65,65,65,66,67,69,71,73,76,80,83,88,93,99,106,115,125,125,115,107,99,93,88,83,79,76,73,71,69,67,66,65,65,65,65,65,67,69,70,73,76,79,83,87,92,98,105,114,124,125,114,106,99,93,87,83,79,76,73,71,68,67,65,65,65,64,65,65,66,68,70,72,75,79,82,87,92,98,105,113,123,124,114,105,98,93,87,82,79,75,72,70,68,66,65,64,64,64,64,65,66,68,70,72,75,78,82,86,92,97,104,112,122,123,113,105,98,92,87,82,78,75,72,70,68,66,65,64,64,64,64,65,66,68,70,72,75,78,82,86,91,97,104,112,122,124,114,106,98,92,86,82,78,75,72,70,68,66,65,64,64,64,64,65,66,68,70,72,75,78,82,86,91,97,104,112,122,124,114,105,98,92,87,82,78,75,72,70,68,66,65,64,64,64,64,65,66,68,70,72,75,78,82,86,91,97,104,112,122,124,114,105,99,92,87,82,78,75,73,70,68,66,65,64,64,64,64,65,66,68,70,72,75,78,82,86,91,97,104,113,123,125,114,106,99,93,87,83,79,76,73,71,69,67,66,64,64,64,64,65,67,68,70,73,76,79,82,87,92,98,105,113,123,126,115,107,100,94,88,83,80,76,74,71,69,67,66,65,65,65,65,66,67,69,71,73,76,79,83,87,92,98,105,114,123,128,117,108,101,94,89,84,80,77,74,72,70,68,67,66,65,65,66,67,68,70,71,74,77,80,83,88,93,99,106,115,125,129,118,109,101,95,90,85,81,78,75,73,71,69,68,67,66,66,67,68,69,70,72,75,78,81,84,89,94,100,108,116,126,130,120,110,103,97,91,86,82,79,76,74,71,70,69,68,67,67,68,69,70,71,73,76,78,82,85,90,95,101,109,118,128,132,121,112,104,98,92,87,83,80,77,75,73,71,70,69,68,68,69,70,71,72,74,77,79,83,87,91,96,103,110,119,129,135,124,114,106,99,94,89,84,81,78,76,74,72,71,70,70,69,70,70,72,74,76,78,81,84,88,92,98,104,111,121,132,138,126,116,108,101,95,90,86,83,80,77,75,73,72,71,71,70,71,72,73,75,77,79,82,85,89,94,99,106,114,123,134,141,128,118,110,103,97,92,88,84,81,78,76,75,73,73,72,72,72,73,74,76,78,81,83,87,91,96,101,108,116,126,137,144,131,121,113,105,99,94,89,86,83,80,78,76,75,74,74,74,74,75,76,78,80,82,85,89,93,98,103,110,119,128,140,148,134,123,114,107,101,96,91,87,84,82,80,78,77,76,75,75,75,76,78,79,81,84,87,90,95,99,105,113,120,131,143,151,137,126,117,110,103,98,93,89,86,84,81,80,79,78,77,77,77,78,79,81,83,86,89,93,97,102,108,115,123,134,147,155,140,129,120,112,106,100,95,91,88,85,83,81,80,79,79,79,79,80,81,83,85,88,91,95,99,104,110,118,127,137,151};

// R G B
static uint16_t _calibration_awb_warming_ls_a[] = {268,256,272};

// R G B
static uint16_t _calibration_awb_warming_ls_d75[] = {271,256,271};

// R G B
static uint16_t _calibration_awb_warming_ls_d50[] = {266,256,271};

// CALIBRATION_NOISE_PROFILE
static uint8_t _calibration_noise_profile[]
 = {0,0,0,0,0,0,0,0,10,30,36,40,43,46,48,49,51,52,53,54,55,56,57,58,59,59,60,61,61,62,62,63,63,64,64,64,65,65,66,66,66,67,67,67,68,68,68,69,69,69,70,70,70,70,71,71,71,71,71,72,72,72,72,73,73,73,73,73,74,74,74,74,74,74,75,75,75,75,75,75,76,76,76,76,76,76,77,77,77,77,77,77,77,78,78,78,78,78,78,78,78,79,79,79,79,79,79,79,79,80,80,80,80,80,80,80,80,80,81,81,81,81,81,81,81,81,81,81};

// CALIBRATION_DEMOSAIC
static uint8_t _calibration_demosaic[]
 = {7,23,29,33,36,38,40,42,43,44,46,47,48,49,50,50,51,52,52,53,53,54,55,55,55,56,56,57,57,58,58,58,59,59,59,60,60,60,61,61,61,62,62,62,62,63,63,63,63,64,64,64,64,64,65,65,65,65,65,66,66,66,66,66,67,67,67,67,67,67,68,68,68,68,68,68,69,69,69,69,69,69,69,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74,74};

// 8-bit normalised noise profile for WDR stitching
static uint8_t _calibration_wdr_np_lut[]
 = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

// CALIBRATION_GAMMA
static uint16_t _calibration_gamma[]
 ={0,430,640,788,901,995,1078,1152,1220,1282,1341,1399,1455,1509,1560,1609,1655,1700,1743,1785,1827,1869,1911,1953,1995,2035,2072,2109,2143,2177,2210,2242,2273,2303,2333,2361,2390,2418,2445,2472,2498,2523,2549,2574,2600,2625,2651,2676,2702,2729,2754,2780,2805,2830,2854,2879,2900,2923,2945,2966,2986,3007,3027,3046,3067,3087,3106,3126,3145,3166,3186,3206,3225,3245,3264,3284,3303,3322,3340,3357,3376,3393,3410,3427,3444,3461,3477,3493,3509,3525,3541,3556,3572,3587,3603,3618,3632,3647,3661,3676,3690,3704,3718,3732,3746,3760,3774,3789,3802,3817,3831,3845,3861,3875,3889,3904,3918,3933,3947,3962,3977,3991,4006,4020,4036,4050,4065,4079,4095}; //{0,101,217,347,537,738,925,1087,1222,1323,1407,1482,1550,1612,1670,1723,1773,1822,1867,1910,1952,1993,2033,2071,2110,2147,2184,2220,2255,2289,2322,2355,2387,2418,2448,2478,2507,2535,2564,2591,2618,2644,2671,2696,2722,2747,2772,2796,2821,2845,2868,2891,2914,2938,2960,2984,3005,3028,3051,3073,3094,3116,3137,3158,3180,3201,3220,3241,3261,3281,3301,3320,3339,3358,3376,3395,3413,3431,3449,3465,3483,3499,3516,3532,3548,3564,3579,3594,3609,3624,3639,3653,3668,3682,3696,3710,3723,3737,3750,3764,3777,3790,3803,3816,3828,3841,3854,3866,3878,3890,3902,3913,3925,3937,3948,3959,3970,3982,3992,4003,4014,4024,4035,4045,4056,4066,4075,4085,4095};

// CALIBRATION_IRIDIX_ASYMMETRY
static uint32_t _calibration_iridix_asymmetry[]
 = {0,62836,120267,172961,221481,266305,307839,346432,382386,415964,447392,476871,504577,530666,555274,578524,600526,621378,641167,659973,677867,694914,711172,726696,741534,755730,769325,782356,794859,806864,818400,829495,840173,850457,860369,869929,879155,888064,896672,904994,913045,920837,928383,935693,942780,949653,956321,962794,969080,975187,981123,986894,992508,997970,1003288,1008466,1013509,1018424,1023215,1027887,1032443,1036889,1041228,1045464,1048575};

static uint32_t _calibration_ca_filter_mem[]
 = {32768,229629,491259,4278943225,4279204855,4262689525,4246239220,4229788915,4213338610,4196888050,4197214450,4180763890,4164313330,4147928050,4131477235,4115091955,4098641140,4082190325,4082516470,4066065655,4066391800,4066652665,4066913530,4067239930,4067500795,4084473340,4101445885,4118418430,4152037375,4185721855,4219340544,4253025024};

// calibration_awb_scene_presets in the following order AWB_DAY_LIGHT AWB_CLOUDY AWB_INCANDESCENT AWB_FLOURESCENT AWB_TWILIGHT AWB_SHADE AWB_WARM_FLOURESCENT
static uint16_t _calibration_awb_scene_presets[7][2] = {
  { 256, 256 },
  { 321, 225 },
  { 176, 354 },
  { 224, 280 },
  { 224, 280 },
  { 358, 209 },
  { 185, 334 }
};

// CALIBRATION_CA_CORRECTION: MIN_CORRECTION, MESH_WIDTH, MESH_HEIGHT
static uint16_t _calibration_ca_correction[] = {1,85,48};

static uint16_t _calibration_ca_correction_mem[][10] = {
  { 57, 65535, 48, 14, 65425, 65504, 65488, 60, 27, 65508 },
  { 65535, 54, 4, 78, 65519, 65462, 65453, 24, 31, 65525 },
  { 65469, 0, 65473, 12, 131, 44, 27, 65509, 65513, 65452 },
  { 65535, 65461, 65524, 65419, 27, 105, 129, 65502, 65529, 65495 }};

static uint32_t _calibration_lut3d_mem[] = {0};

static uint32_t _calibration_decompander0_mem[] = {0, 32768, 65536, 98304, 131072, 163840, 196608, 229376, 262144, 294912, 327680, 360448, 393216, 425984, 458752, 491520, 524288, 557055, 589823, 622591, 655359, 688127, 720895, 753663, 786431, 819199, 851967, 884735, 917503, 950271, 983039, 1015807, 1048575};

static uint32_t _calibration_decompander1_mem[] = {0, 4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768, 36864, 40960, 45056, 49152, 53248, 57344, 61440, 65536, 69632, 73728, 77824, 81920, 86016, 90112, 94208, 98304, 102400, 106496, 110592, 114688, 118784, 122880, 126976, 131072, 135168, 139264, 143360, 147456, 151552, 155648, 159744, 163840, 167936, 172032, 176128, 180224, 184320, 188416, 192512, 196608, 200704, 204800, 208896, 212992, 217088, 221184, 225280, 229376, 233472, 237568, 241664, 245760, 249856, 253952, 258048, 262144, 266240, 270336, 274432, 278528, 282624, 286720, 290816, 294912, 299008, 303104, 307200, 311296, 315392, 319488, 323584, 327680, 331776, 335872, 339968, 344064, 348160, 352256, 356352, 360448, 364544, 368640, 372736, 376832, 380928, 385024, 389120, 393216, 397312, 401408, 405504, 409600, 413696, 417792, 421888, 425984, 430080, 434176, 438272, 442368, 446464, 450560, 454656, 458752, 462848, 466944, 471040, 475136, 479232, 483328, 487424, 491520, 495616, 499712, 503808, 507904, 512000, 516096, 520192, 524288, 528383, 532479, 536575, 540671, 544767, 548863, 552959, 557055, 561151, 565247, 569343, 573439, 577535, 581631, 585727, 589823, 593919, 598015, 602111, 606207, 610303, 614399, 618495, 622591, 626687, 630783, 634879, 638975, 643071, 647167, 651263, 655359, 659455, 663551, 667647, 671743, 675839, 679935, 684031, 688127, 692223, 696319, 700415, 704511, 708607, 712703, 716799, 720895, 724991, 729087, 733183, 737279, 741375, 745471, 749567, 753663, 757759, 761855, 765951, 770047, 774143, 778239, 782335, 786431, 790527, 794623, 798719, 802815, 806911, 811007, 815103, 819199, 823295, 827391, 831487, 835583, 839679, 843775, 847871, 851967, 856063, 860159, 864255, 868351, 872447, 876543, 880639, 884735, 888831, 892927, 897023, 901119, 905215, 909311, 913407, 917503, 921599, 925695, 929791, 933887, 937983, 942079, 946175, 950271, 954367, 958463, 962559, 966655, 970751, 974847, 978943, 983039, 987135, 991231, 995327, 999423, 1003519, 1007615, 1011711, 1015807, 1019903, 1023999, 1028095, 1032191, 1036287, 1040383, 1044479, 1048575};

// CALIBRATION_SHADING_RADIAL_R
static uint16_t _calibration_shading_radial_r[] = {4096,4098,4099,4101,4103,4104,4106,4108,4110,4112,4114,4116,4118,4120,4122,4124,4126,4128,4131,4133,4136,4138,4141,4144,4146,4149,4152,4155,4158,4161,4165,4168,4171,4175,4178,4182,4186,4190,4194,4198,4202,4206,4211,4215,4220,4225,4229,4234,4239,4245,4250,4255,4261,4266,4272,4278,4284,4290,4296,4303,4309,4316,4323,4329,4336,4344,4351,4358,4366,4373,4381,4389,4397,4405,4413,4422,4430,4439,4448,4457,4466,4475,4485,4494,4504,4514,4524,4534,4544,4554,4565,4575,4586,4597,4608,4619,4630,4642,4653,4665,4677,4688,4700,4713,4725,4737,4750,4762,4775,4788,4800,4813,4826,4840,4853,4866,4880,4893,4907,4920,4934,4948,4962,4976,4990,5004,5018,5032,5046};

// CALIBRATION_SHADING_RADIAL_G
static uint16_t _calibration_shading_radial_g[] = {4096,4098,4099,4100,4102,4103,4105,4106,4108,4109,4111,4112,4114,4115,4117,4119,4120,4122,4124,4125,4127,4129,4131,4133,4135,4137,4140,4142,4144,4147,4149,4152,4155,4158,4161,4164,4167,4170,4173,4177,4180,4184,4188,4192,4196,4200,4204,4208,4213,4217,4222,4227,4232,4237,4242,4248,4253,4259,4265,4271,4277,4283,4290,4296,4303,4310,4317,4324,4332,4339,4347,4355,4363,4371,4379,4387,4396,4405,4414,4423,4432,4441,4451,4460,4470,4480,4490,4501,4511,4522,4533,4544,4555,4566,4577,4589,4601,4612,4624,4636,4649,4661,4673,4686,4699,4712,4725,4738,4751,4764,4778,4791,4805,4819,4832,4846,4860,4874,4888,4902,4916,4930,4945,4959,4973,4987,5001,5016,5030};

// CALIBRATION_SHADING_RADIAL_B
static uint16_t _calibration_shading_radial_b[] = {4096,4097,4098,4099,4100,4101,4101,4102,4103,4104,4105,4106,4107,4108,4108,4109,4110,4111,4113,4114,4115,4116,4117,4119,4120,4122,4123,4125,4127,4128,4130,4132,4134,4136,4139,4141,4143,4146,4148,4151,4154,4157,4160,4163,4166,4170,4173,4177,4181,4185,4189,4193,4197,4202,4206,4211,4216,4221,4226,4231,4237,4242,4248,4254,4260,4266,4272,4279,4286,4292,4299,4306,4314,4321,4328,4336,4344,4352,4360,4368,4377,4386,4394,4403,4412,4422,4431,4440,4450,4460,4470,4480,4490,4501,4511,4522,4533,4544,4555,4566,4577,4589,4600,4612,4624,4636,4648,4660,4672,4684,4697,4709,4722,4734,4747,4760,4773,4786,4798,4811,4824,4837,4850,4863,4876,4889,4902,4915,4928};

static LookupTable calibration_shading_radial_r = { .ptr = _calibration_shading_radial_r, .rows = 1, .cols = sizeof(_calibration_shading_radial_r) / sizeof(_calibration_shading_radial_r[0]), .width = sizeof(_calibration_shading_radial_r[0] ) };
static LookupTable calibration_shading_radial_g = { .ptr = _calibration_shading_radial_g, .rows = 1, .cols = sizeof(_calibration_shading_radial_g) / sizeof(_calibration_shading_radial_g[0]), .width = sizeof(_calibration_shading_radial_g[0] ) };
static LookupTable calibration_shading_radial_b = { .ptr = _calibration_shading_radial_b, .rows = 1, .cols = sizeof(_calibration_shading_radial_b) / sizeof(_calibration_shading_radial_b[0]), .width = sizeof(_calibration_shading_radial_b[0] ) };
static LookupTable calibration_decompander0_mem = {.ptr = _calibration_decompander0_mem, .rows = 1, .cols = sizeof( _calibration_decompander0_mem ) / sizeof( _calibration_decompander0_mem[0] ), .width = sizeof( _calibration_decompander0_mem[0] )};
static LookupTable calibration_decompander1_mem = {.ptr = _calibration_decompander1_mem, .rows = 1, .cols = sizeof( _calibration_decompander1_mem ) / sizeof( _calibration_decompander1_mem[0] ), .width = sizeof( _calibration_decompander1_mem[0] )};

static LookupTable calibration_awb_scene_presets = {.ptr = _calibration_awb_scene_presets, .cols = 2, .rows = sizeof( _calibration_awb_scene_presets ) / sizeof( _calibration_awb_scene_presets[0] ), .width = sizeof( _calibration_awb_scene_presets[0][0] )};
static LookupTable calibration_light_src = {.ptr = _calibration_light_src, .cols = 2, .rows = sizeof( _calibration_light_src ) / sizeof( _calibration_light_src[0] ), .width = sizeof( _calibration_light_src[0][0] )};
static LookupTable calibration_rg_pos = {.ptr = _calibration_rg_pos, .rows = 1, .cols = sizeof( _calibration_rg_pos ) / sizeof( _calibration_rg_pos[0] ), .width = sizeof( _calibration_rg_pos[0] )};
static LookupTable calibration_bg_pos = {.ptr = _calibration_bg_pos, .rows = 1, .cols = sizeof( _calibration_bg_pos ) / sizeof( _calibration_bg_pos[0] ), .width = sizeof( _calibration_bg_pos[0] )};
static LookupTable calibration_mesh_rgbg_weight = {.ptr = _calibration_mesh_rgbg_weight, .cols = 15, .rows = sizeof( _calibration_mesh_rgbg_weight ) / sizeof( _calibration_mesh_rgbg_weight[0] ), .width = sizeof( _calibration_mesh_rgbg_weight[0][0] )};
static LookupTable calibration_mesh_ls_weight = {.ptr = _calibration_mesh_ls_weight, .cols = 15, .rows = sizeof( _calibration_mesh_ls_weight ) / sizeof( _calibration_mesh_ls_weight[0] ), .width = sizeof( _calibration_mesh_ls_weight[0][0] )};
static LookupTable calibration_mesh_color_temperature = {.ptr = _calibration_mesh_color_temperature, .cols = 15, .rows = sizeof( _calibration_mesh_color_temperature ) / sizeof( _calibration_mesh_color_temperature[0] ), .width = sizeof( _calibration_mesh_color_temperature[0][0] )};
static LookupTable calibration_wb_strength = {.ptr = _calibration_wb_strength, .rows = 1, .cols = sizeof( _calibration_wb_strength ) / sizeof( _calibration_wb_strength[0] ), .width = sizeof( _calibration_wb_strength[0] )};
static LookupTable calibration_sky_lux_th = {.ptr = _calibration_sky_lux_th, .rows = 1, .cols = sizeof( _calibration_sky_lux_th ) / sizeof( _calibration_sky_lux_th[0] ), .width = sizeof( _calibration_sky_lux_th[0] )};
static LookupTable calibration_ct_rg_pos_calc = {.ptr = _calibration_ct_rg_pos_calc, .rows = 1, .cols = sizeof( _calibration_ct_rg_pos_calc ) / sizeof( _calibration_ct_rg_pos_calc[0] ), .width = sizeof( _calibration_ct_rg_pos_calc[0] )};
static LookupTable calibration_ct_bg_pos_calc = {.ptr = _calibration_ct_bg_pos_calc, .rows = 1, .cols = sizeof( _calibration_ct_bg_pos_calc ) / sizeof( _calibration_ct_bg_pos_calc[0] ), .width = sizeof( _calibration_ct_bg_pos_calc[0] )};
static LookupTable calibration_color_temp = {.ptr = _calibration_color_temp, .rows = 1, .cols = sizeof( _calibration_color_temp ) / sizeof( _calibration_color_temp[0] ), .width = sizeof( _calibration_color_temp[0] )};
static LookupTable calibration_ct65pos = {.ptr = _calibration_ct65pos, .rows = 1, .cols = sizeof( _calibration_ct65pos ) / sizeof( _calibration_ct65pos[0] ), .width = sizeof( _calibration_ct65pos[0] )};
static LookupTable calibration_ct40pos = {.ptr = _calibration_ct40pos, .rows = 1, .cols = sizeof( _calibration_ct40pos ) / sizeof( _calibration_ct40pos[0] ), .width = sizeof( _calibration_ct40pos[0] )};
static LookupTable calibration_ct30pos = {.ptr = _calibration_ct30pos, .rows = 1, .cols = sizeof( _calibration_ct30pos ) / sizeof( _calibration_ct30pos[0] ), .width = sizeof( _calibration_ct30pos[0] )};
static LookupTable calibration_evtolux_ev_lut = {.ptr = _calibration_evtolux_ev_lut, .rows = 1, .cols = sizeof( _calibration_evtolux_ev_lut ) / sizeof( _calibration_evtolux_ev_lut[0] ), .width = sizeof( _calibration_evtolux_ev_lut[0] )};
static LookupTable calibration_evtolux_lux_lut = {.ptr = _calibration_evtolux_lux_lut, .rows = 1, .cols = sizeof( _calibration_evtolux_lux_lut ) / sizeof( _calibration_evtolux_lux_lut[0] ), .width = sizeof( _calibration_evtolux_lux_lut[0] )};
static LookupTable calibration_black_level_r = {.ptr = _calibration_black_level_r, .cols = 2, .rows = sizeof( _calibration_black_level_r ) / sizeof( _calibration_black_level_r[0] ), .width = sizeof( _calibration_black_level_r[0][0] )};
static LookupTable calibration_black_level_gr = {.ptr = _calibration_black_level_gr, .cols = 2, .rows = sizeof( _calibration_black_level_gr ) / sizeof( _calibration_black_level_gr[0] ), .width = sizeof( _calibration_black_level_gr[0][0] )};
static LookupTable calibration_black_level_gb = {.ptr = _calibration_black_level_gb, .cols = 2, .rows = sizeof( _calibration_black_level_gb ) / sizeof( _calibration_black_level_gb[0] ), .width = sizeof( _calibration_black_level_gb[0][0] )};
static LookupTable calibration_black_level_b = {.ptr = _calibration_black_level_b, .cols = 2, .rows = sizeof( _calibration_black_level_b ) / sizeof( _calibration_black_level_b[0] ), .width = sizeof( _calibration_black_level_b[0][0] )};
static LookupTable calibration_static_wb = {.ptr = _calibration_static_wb, .rows = 1, .cols = sizeof( _calibration_static_wb ) / sizeof( _calibration_static_wb[0] ), .width = sizeof( _calibration_static_wb[0] )};
static LookupTable calibration_mt_absolute_ls_a_ccm = {.ptr = _calibration_mt_absolute_ls_a_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_a_ccm ) / sizeof( _calibration_mt_absolute_ls_a_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_a_ccm[0] )};
static LookupTable calibration_mt_absolute_ls_d40_ccm = {.ptr = _calibration_mt_absolute_ls_d40_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_d40_ccm ) / sizeof( _calibration_mt_absolute_ls_d40_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_d40_ccm[0] )};
static LookupTable calibration_mt_absolute_ls_d50_ccm = {.ptr = _calibration_mt_absolute_ls_d50_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_d50_ccm ) / sizeof( _calibration_mt_absolute_ls_d50_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_d50_ccm[0] )};
static LookupTable calibration_shading_ls_a_r = {.ptr = _calibration_shading_ls_a_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_r ) / sizeof( _calibration_shading_ls_a_r[0] ), .width = sizeof( _calibration_shading_ls_a_r[0] )};
static LookupTable calibration_shading_ls_a_g = {.ptr = _calibration_shading_ls_a_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_g ) / sizeof( _calibration_shading_ls_a_g[0] ), .width = sizeof( _calibration_shading_ls_a_g[0] )};
static LookupTable calibration_shading_ls_a_b = {.ptr = _calibration_shading_ls_a_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_b ) / sizeof( _calibration_shading_ls_a_b[0] ), .width = sizeof( _calibration_shading_ls_a_b[0] )};
static LookupTable calibration_shading_ls_tl84_r = {.ptr = _calibration_shading_ls_tl84_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_r ) / sizeof( _calibration_shading_ls_tl84_r[0] ), .width = sizeof( _calibration_shading_ls_tl84_r[0] )};
static LookupTable calibration_shading_ls_tl84_g = {.ptr = _calibration_shading_ls_tl84_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_g ) / sizeof( _calibration_shading_ls_tl84_g[0] ), .width = sizeof( _calibration_shading_ls_tl84_g[0] )};
static LookupTable calibration_shading_ls_tl84_b = {.ptr = _calibration_shading_ls_tl84_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_b ) / sizeof( _calibration_shading_ls_tl84_b[0] ), .width = sizeof( _calibration_shading_ls_tl84_b[0] )};
static LookupTable calibration_shading_ls_d65_r = {.ptr = _calibration_shading_ls_d65_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_r ) / sizeof( _calibration_shading_ls_d65_r[0] ), .width = sizeof( _calibration_shading_ls_d65_r[0] )};
static LookupTable calibration_shading_ls_d65_g = {.ptr = _calibration_shading_ls_d65_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_g ) / sizeof( _calibration_shading_ls_d65_g[0] ), .width = sizeof( _calibration_shading_ls_d65_g[0] )};
static LookupTable calibration_shading_ls_d65_b = {.ptr = _calibration_shading_ls_d65_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_b ) / sizeof( _calibration_shading_ls_d65_b[0] ), .width = sizeof( _calibration_shading_ls_d65_b[0] )};
static LookupTable calibration_awb_warming_ls_a = {.ptr = _calibration_awb_warming_ls_a, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_a ) / sizeof( _calibration_awb_warming_ls_a[0] ), .width = sizeof( _calibration_awb_warming_ls_a[0] )};
static LookupTable calibration_awb_warming_ls_d50 = {.ptr = _calibration_awb_warming_ls_d50, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_d50 ) / sizeof( _calibration_awb_warming_ls_d50[0] ), .width = sizeof( _calibration_awb_warming_ls_d50[0] )};
static LookupTable calibration_awb_warming_ls_d75 = {.ptr = _calibration_awb_warming_ls_d75, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_d75 ) / sizeof( _calibration_awb_warming_ls_d75[0] ), .width = sizeof( _calibration_awb_warming_ls_d75[0] )};
static LookupTable calibration_noise_profile = {.ptr = _calibration_noise_profile, .rows = 1, .cols = sizeof( _calibration_noise_profile ) / sizeof( _calibration_noise_profile[0] ), .width = sizeof( _calibration_noise_profile[0] )};
static LookupTable calibration_demosaic = {.ptr = _calibration_demosaic, .rows = 1, .cols = sizeof( _calibration_demosaic ) / sizeof( _calibration_demosaic[0] ), .width = sizeof( _calibration_demosaic[0] )};
static LookupTable calibration_wdr_np_lut = {.ptr = _calibration_wdr_np_lut, .rows = 1, .cols = sizeof( _calibration_wdr_np_lut ) / sizeof( _calibration_wdr_np_lut[0] ), .width = sizeof( _calibration_wdr_np_lut[0] )};
static LookupTable calibration_gamma = {.ptr = _calibration_gamma, .rows = 1, .cols = sizeof( _calibration_gamma ) / sizeof( _calibration_gamma[0] ), .width = sizeof( _calibration_gamma[0] )};
static LookupTable calibration_iridix_asymmetry = {.ptr = _calibration_iridix_asymmetry, .rows = 1, .cols = sizeof( _calibration_iridix_asymmetry ) / sizeof( _calibration_iridix_asymmetry[0] ), .width = sizeof( _calibration_iridix_asymmetry[0] )};
static LookupTable calibration_ca_filter_mem = {.ptr = _calibration_ca_filter_mem, .rows = 1, .cols = sizeof( _calibration_ca_filter_mem ) / sizeof( _calibration_ca_filter_mem[0] ), .width = sizeof( _calibration_ca_filter_mem[0] )};
static LookupTable calibration_ca_correction = {.ptr = _calibration_ca_correction, .rows = 1, .cols = sizeof( _calibration_ca_correction ) / sizeof( _calibration_ca_correction[0] ), .width = sizeof( _calibration_ca_correction[0] )};
static LookupTable calibration_ca_correction_mem = {.ptr = _calibration_ca_correction_mem, .cols = 10, .rows = sizeof( _calibration_ca_correction_mem ) / sizeof( _calibration_ca_correction_mem[0] ), .width = sizeof( _calibration_ca_correction_mem[0][0] )};
static LookupTable calibration_lut3d_mem = {.ptr = _calibration_lut3d_mem, .rows = 1, .cols = sizeof( _calibration_lut3d_mem ) / sizeof( _calibration_lut3d_mem[0] ), .width = sizeof( _calibration_lut3d_mem[0] )};

uint32_t get_calibrations_static_linear_sc4238( ACameraCalibrations *c )
{
    uint32_t result = 0;
    if ( c != 0 ) {
        c->calibrations[CALIBRATION_SHADING_RADIAL_R] = &calibration_shading_radial_r;
        c->calibrations[CALIBRATION_SHADING_RADIAL_G] = &calibration_shading_radial_g;
        c->calibrations[CALIBRATION_SHADING_RADIAL_B] = &calibration_shading_radial_b;
        c->calibrations[CALIBRATION_DECOMPANDER0_MEM] = &calibration_decompander0_mem;
        c->calibrations[CALIBRATION_DECOMPANDER1_MEM] = &calibration_decompander1_mem;
        c->calibrations[CALIBRATION_LIGHT_SRC] = &calibration_light_src;
        c->calibrations[CALIBRATION_RG_POS] = &calibration_rg_pos;
        c->calibrations[CALIBRATION_BG_POS] = &calibration_bg_pos;
        c->calibrations[CALIBRATION_MESH_RGBG_WEIGHT] = &calibration_mesh_rgbg_weight;
        c->calibrations[CALIBRATION_MESH_LS_WEIGHT] = &calibration_mesh_ls_weight;
        c->calibrations[CALIBRATION_MESH_COLOR_TEMPERATURE] = &calibration_mesh_color_temperature;
        c->calibrations[CALIBRATION_WB_STRENGTH] = &calibration_wb_strength;
        c->calibrations[CALIBRATION_SKY_LUX_TH] = &calibration_sky_lux_th;
        c->calibrations[CALIBRATION_CT_RG_POS_CALC] = &calibration_ct_rg_pos_calc;
        c->calibrations[CALIBRATION_CT_BG_POS_CALC] = &calibration_ct_bg_pos_calc;
        c->calibrations[CALIBRATION_COLOR_TEMP] = &calibration_color_temp;
        c->calibrations[CALIBRATION_CT65POS] = &calibration_ct65pos;
        c->calibrations[CALIBRATION_CT40POS] = &calibration_ct40pos;
        c->calibrations[CALIBRATION_CT30POS] = &calibration_ct30pos;
        c->calibrations[CALIBRATION_EVTOLUX_EV_LUT] = &calibration_evtolux_ev_lut;
        c->calibrations[CALIBRATION_EVTOLUX_LUX_LUT] = &calibration_evtolux_lux_lut;
        c->calibrations[CALIBRATION_BLACK_LEVEL_R] = &calibration_black_level_r;
        c->calibrations[CALIBRATION_BLACK_LEVEL_GR] = &calibration_black_level_gr;
        c->calibrations[CALIBRATION_BLACK_LEVEL_GB] = &calibration_black_level_gb;
        c->calibrations[CALIBRATION_BLACK_LEVEL_B] = &calibration_black_level_b;
        c->calibrations[CALIBRATION_STATIC_WB] = &calibration_static_wb;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_A_CCM] = &calibration_mt_absolute_ls_a_ccm;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_D40_CCM] = &calibration_mt_absolute_ls_d40_ccm;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_D50_CCM] = &calibration_mt_absolute_ls_d50_ccm;
        c->calibrations[CALIBRATION_SHADING_LS_A_R] = &calibration_shading_ls_a_r;
        c->calibrations[CALIBRATION_SHADING_LS_A_G] = &calibration_shading_ls_a_g;
        c->calibrations[CALIBRATION_SHADING_LS_A_B] = &calibration_shading_ls_a_b;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_R] = &calibration_shading_ls_tl84_r;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_G] = &calibration_shading_ls_tl84_g;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_B] = &calibration_shading_ls_tl84_b;
        c->calibrations[CALIBRATION_SHADING_LS_D65_R] = &calibration_shading_ls_d65_r;
        c->calibrations[CALIBRATION_SHADING_LS_D65_G] = &calibration_shading_ls_d65_g;
        c->calibrations[CALIBRATION_SHADING_LS_D65_B] = &calibration_shading_ls_d65_b;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_A] = &calibration_awb_warming_ls_a;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_D50] = &calibration_awb_warming_ls_d50;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_D75] = &calibration_awb_warming_ls_d75;
        c->calibrations[CALIBRATION_NOISE_PROFILE] = &calibration_noise_profile;
        c->calibrations[CALIBRATION_DEMOSAIC] = &calibration_demosaic;
        c->calibrations[CALIBRATION_WDR_NP_LUT] = &calibration_wdr_np_lut;
        c->calibrations[CALIBRATION_GAMMA] = &calibration_gamma;
        c->calibrations[CALIBRATION_IRIDIX_ASYMMETRY] = &calibration_iridix_asymmetry;
        c->calibrations[CALIBRATION_AWB_SCENE_PRESETS] = &calibration_awb_scene_presets;
        c->calibrations[CALIBRATION_CA_FILTER_MEM] = &calibration_ca_filter_mem;
        c->calibrations[CALIBRATION_CA_CORRECTION] = &calibration_ca_correction;
        c->calibrations[CALIBRATION_CA_CORRECTION_MEM] = &calibration_ca_correction_mem;
        c->calibrations[CALIBRATION_LUT3D_MEM] = &calibration_lut3d_mem;
    } else {
        result = -1;
    }
    return result;
}
